package com.moorror.codegenvel.common.tree.actions.gencode;

import com.intellij.icons.AllIcons;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.project.DumbAware;
import com.moorror.codegenvel.view.window.codegen.domain.ExtractFileDesc;
import org.jetbrains.annotations.NotNull;

import java.util.function.Consumer;

/**
 * @Author jiyanghuang
 * @Date 2025/8/24 17:38
 */
public class ExtractVelocityFileContentReplaceAction extends AnAction implements DumbAware {

    private final ExtractFileDesc extractFileDesc;
    private final Consumer<ExtractFileDesc> consumer;
    public ExtractVelocityFileContentReplaceAction(ExtractFileDesc extractFileDesc, Consumer<ExtractFileDesc> consumer) {
        super("Replace Variable To Velocity Variable", "Replace Variable To Velocity Variable", AllIcons.Actions.Edit);
        this.extractFileDesc = extractFileDesc;
        this.consumer = consumer;
    }

    @Override
    public void actionPerformed(@NotNull AnActionEvent e) {
        if(null != consumer){
            consumer.accept(extractFileDesc);
        }
    }
}
